package mySwing;

import java.util.Vector;

public class myBar extends javax.swing.JPanel {

    private Vector icaoButtons;// = new Vector<icaoB>();
    public myBar() {
        initComponents();
    }

    public Vector<icaoB> getVectorForSave() {
        icaoButtons = new Vector<icaoB>();
        for (int i = 0; i < jToolBar1.getComponentCount(); i++) {
            icaoButtons.add(jToolBar1.getComponent(i));
        }
        return icaoButtons;
    }

    public void load(Vector<icaoB> inV) {
        // jToolBar1.removeAll();
        for (int i = 0; i < inV.size(); i++) {
            this.addAeroButton(inV.get(i));
        }
    }

    public void clearAll() {
        jToolBar1.removeAll();
        jToolBar1.repaint();
    }

    public void addAeroButton(icaoB inB) {
        jToolBar1.add(inB);
        jToolBar1.repaint();
        jToolBar1.validate();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jToolBar1 = new javax.swing.JToolBar();

        setAutoscrolls(true);

        jScrollPane1.setAutoscrolls(true);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setAutoscrolls(true);
        jScrollPane1.setViewportView(jToolBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
    public Vector getIcaoButtons() {
        return icaoButtons;
    }

    public void setIcaoButtons(Vector icaoButtons) {
        this.icaoButtons = icaoButtons;
    }
}
